<template>
  <div class="view-content-box py-20">
    <LoadList
      :query-params="queryParams"
      :loadingData="postAgentShopDevicePage"
      class="view-content"
    >
      <template #list="{ list }">
        <div class="device-list">
          <div
            v-for="(item, index) in list"
            :key="item.id || index"
            class="d-flex"
            @click="toOrderList(item)"
          >
            <div class="item-lf">
              <div class="d-flex a-center mb-20">
                <img class="no-icon" src="@/assets/bian.png" alt="" />
                <div class="code">设备编码：{{ item.deviceNo }}</div>
              </div>
              <div class="msg">
                <img class="msg-img" :src="item.image" alt="" />
                <div class="msg-status">
                  <div>所属商户: {{ item.shopName }}</div>
                  <div :class="['status', 'success-stauts', 'fail-status']">
                    设备状态：<span>{{
                      item.onlineStatus == 0 ? "在线" : "离线"
                    }}</span>
                  </div>
                </div>
              </div>
              <div class="address">
                设备所在地区：{{
                  item.province + "/" + item.city + "/" + item.area
                }}
              </div>
            </div>
            <div class="item-ri">
              <div class="num-title">设备服务次数</div>
              <div class="num">{{ item.serviceNum }}</div>
            </div>
          </div>
        </div>
      </template>
    </LoadList>
  </div>
</template>

<script setup>
import { postMpDeviceStatistics, postAgentShopDevicePage } from "@/api/index";
import { onMounted } from "vue";
const router = useRouter();
const route = useRoute();
const queryParams = reactive({
  shopId: route.query.id,
});
const detail = ref({
  deviceNum: "112",
  errorNum: "112",
});
const area = ref("");
const getStatistics = () => {
  postMpDeviceStatistics().then((res) => {
    console.log(res);
    detail.value = res.data;
  });
};
const toOrderList = (item) => {
  router.push({
    path: "/order/list",
    query: { id: item.id, shopId: route.query.id },
  });
};

onMounted(() => {
  getStatistics();
  // getList();
});
</script>

<style lang="less" scoped>
.head {
  width: 100%;
  height: 276px;
  background: url("@/assets/bg1.png") no-repeat center;
  position: relative;
  padding-top: 28px;
  .title {
    font-size: 40px;
    color: #151515;
    font-weight: 600;
    text-align: center;
  }
  .search-box {
    position: absolute;
    bottom: 36px;
    width: 100%;
  }
}
.area-box {
  font-size: 32px;
  color: #151515;
}
.address-icon {
  width: 36px;
  height: 36px;
}
.area-msg {
  font-size: 24px;
  color: #151515;
  line-height: 34px;
  display: flex;
  align-items: center;
  margin-left: 10px;
  .icon {
    width: 24px;
    height: 24px;
  }
}

.type-list {
  display: flex;
  gap: 20px;
  > .device-type {
    flex: 1;
    // height: 250px;
    padding: 40px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    &:first-child {
      background: #b5d4ff;
    }
    &:last-child {
      background: #fedc00;
    }
    .num {
      font-size: 46px;
      font-weight: 600;
      margin-bottom: 24px;
    }
    .type {
      font-size: 30px;
    }
  }
}
.add-btn {
  width: 100%;
  height: 70px;
  line-height: 70px;
  text-align: center;
  background: #fff;
  border-radius: 30px;
  color: #000;
  font-size: 32px;
  margin: 30px 0;
}
.device-list {
  display: flex;
  // gap: 20px;
  padding: 0 32px;
  flex-wrap: wrap;
  > div {
    width: 100%;
    // height: 280px;
    color: #969696;
    font-size: 26px;
    background: #fff;
    // border-radius: 10px;
    // text-align: center;
    margin-bottom: 24px;

    border-radius: 16px;
    overflow: hidden;

    // &:nth-child(2n + 1) {
    //   margin-right: 30px;
    // }
  }
  .item-lf {
    flex: 1;
    padding: 20px;
    .no-icon {
      width: 36px;
      height: 36px;
      margin-right: 10px;
    }

    .code {
      font-size: 26px;
      color: #151515;
    }
    .msg {
      display: flex;
      margin-bottom: 14px;
      .msg-img {
        width: 140px;
        height: 140px;
        margin-right: 16px;
        border-radius: 4px;
      }
      .msg-status {
        padding: 14px 0;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
      }
    }
    .address {
      font-size: 22px;
      color: #6c6c6c;
      line-height: 28px;
    }
  }
  .item-ri {
    padding-top: 20px;
    width: 192px;
    background: url("@/assets/bg_shebei.png") no-repeat center;
    text-align: center;
    .num-title {
      font-weight: 600;
      font-size: 26px;
      color: #ffffff;
      margin-bottom: 36px;
    }
    .num {
      font-weight: 600;
      font-size: 78px;
      color: #ff4e00;
    }
  }

  .basic-msg {
    height: 94px;
    background: #e9e9e9;
    display: flex;
    align-items: center;
    padding: 0 20px;
    .name {
      text-align: left;
      margin-left: 14px;
      font-size: 32px;
      color: #151515;
      font-weight: 600;
    }
    img {
      width: 48px;
      height: 48px;
    }
    .time {
      font-size: 24px;
      color: #6c6c6c;
    }
  }
  .data-item {
    display: flex;
    align-items: center;
    height: 178px;
    justify-content: space-between;
    padding: 32px;
    .num {
      font-size: 44px;
      color: #151515;
      margin-bottom: 14px;
    }
    .type {
      font-size: 24px;
      color: #6c6c6c;
    }
  }
  .status {
    color: #6a6a6a;
    > .error {
      color: #e55f6a;
    }
  }
}

.use-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  .all-item {
    background: #fffbe0;
    position: relative;
    height: 35px;
    text-align: center;
    .use-item {
      position: absolute;
      height: 100%;
      top: 0;
      left: 0;
      z-index: 1;
      &.radius {
        border-radius: 0 12px 12px 0;
      }
    }
    &:nth-child(1) {
      .use-item {
        background: #fedc00;
      }
    }
    &:nth-child(2) {
      .use-item {
        background: #f93c31;
      }
    }
    &:nth-child(3) {
      .use-item {
        background: #8dc936;
      }
    }
    span {
      position: relative;
      z-index: 2;
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100%;
      font-size: 24px;
    }
  }
}
</style>
